#include <vector>
using namespace std;

class Solution {
public:
    int longestConsecutive(vector<int>& nums) {
    if (nums.empty()) return 0;

    sort(nums.begin(), nums.end());

    int longest = 1;
    int currentLength = 1;

    for (int i = 1; i < nums.size(); ++i) {
        // 跳过重复元素
        if (nums[i] == nums[i - 1]) {
            continue;
        }
        // 如果当前数与前一个相差1，则连续
        else if (nums[i] == nums[i - 1] + 1) {
            currentLength++;
            longest = max(longest, currentLength);
        }
        // 否则重置当前长度
        else {
            currentLength = 1;
        }
    }

    return longest;
}
};

int main(){

    return 0;
}